package com.portal.framework.webutil;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.portal.framework.util.NumberUtil;


/**
 * 
 * 页面辅助类
 * 
 */

public class WebConstBean {
	private String isNoOrYes;// 0 否 1 是
	private String formatLK;//格式化金额(含千分位)
	

	private String splitMode;
	private List<KeyValBean> splitList=new ArrayList<KeyValBean>();//分割方式列表
	
	private List<KeyValBean> fileTypeList=new ArrayList<KeyValBean>();//文件方式列表
	
	
	private String logLevel;// 日志级别
	private List<EnumItem> logLevelList=new ArrayList<EnumItem>();// 日志级别列表
	
	private String logFlag;// 日志状态
	private List<EnumItem> logFlagList=new ArrayList<EnumItem>();// 日志状态列表
	

	public String getLogLevel() {
		try {
			switch (Integer.parseInt(logLevel)) {
			case 1:
				return "严重";
			case 2:
				return "警告";
			case 3:
				return "正常";
			}
		} catch (Exception e) {
			return "";
		}
		return logLevel;
	}

	public String getLogFlag() {
		try {
			switch (Integer.parseInt(logFlag)) {
			case 0:
				return "未处理";
			case 1:
				return "已处理";
			}
		} catch (Exception e) {
			return "";
		}
		return logFlag;
	}

	public List<EnumItem> getLogLevelList() {
		logLevelList.add(new EnumItem(1,"严重"));
		logLevelList.add(new EnumItem(2,"警告"));
		logLevelList.add(new EnumItem(3,"正常"));
		return logLevelList;
	}

	public List<EnumItem> getLogFlagList() {
		logFlagList.add(new EnumItem(0,"未处理"));
		logFlagList.add(new EnumItem(1,"已处理"));
		return logFlagList;
	}

	public String getSplitMode() {
		splitList = this.getSplitList();
		for (Iterator iterator = splitList.iterator(); iterator.hasNext();) {
			KeyValBean kvBean = (KeyValBean) iterator.next();
			if(kvBean.getKeybean().equals(splitMode)){
				return kvBean.getValuebean();
			}
		}
		return splitMode;
	}

	public void setSplitMode(String splitMode) {
		this.splitMode = splitMode;
	}

	public List<KeyValBean> getFileTypeList() {
		fileTypeList.add(new KeyValBean("DATA","DATA"));
		fileTypeList.add(new KeyValBean("TEXT","TEXT"));
		fileTypeList.add(new KeyValBean("XML","XML"));
		fileTypeList.add(new KeyValBean("EXCEL","EXCEL"));
		return fileTypeList;
	}

	public void setFileTypeList(List<KeyValBean> fileTypeList) {
		this.fileTypeList = fileTypeList;
	}

	public List<KeyValBean> getSplitList() {
		splitList.add(new KeyValBean("空格"," "));
		splitList.add(new KeyValBean("分号",";"));
		splitList.add(new KeyValBean("逗号",","));
		splitList.add(new KeyValBean("Tab","	"));
		splitList.add(new KeyValBean("-","-"));
		splitList.add(new KeyValBean("@","@"));
		splitList.add(new KeyValBean("#","#"));
		splitList.add(new KeyValBean("&","&"));
		return splitList;
	}
	
	public void setSplitList(List<KeyValBean> splitList) {
		this.splitList = splitList;
	}
	
	

	public String getIsNoOrYes() {
		try {
			switch (Integer.parseInt(isNoOrYes)) {
			case 0:
				return "否";
			case 1:
				return "是";
			}
		} catch (Exception e) {
			return "否";
		}
		return isNoOrYes;
	}

	public void setIsNoOrYes(String isNoOrYes) {
		this.isNoOrYes = isNoOrYes;
	}

	

	public String getFormatLK() {
		if(formatLK==null || "".equals(formatLK)){
			return "0.00";
		}
		Double amt=new Double(formatLK);
		formatLK=NumberUtil.formatNumeric(amt,"###0.0000");
		return formatLK;
	}

	public void setFormatLK(String formatLK) {
		this.formatLK = formatLK;
	}

}
